package acwing;

import java.io.*;

public class ac800 {
    static final int N = 100010;
    static final int[] a = new int[N];
    static final int[] b = new int[N];

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = in.readLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        int x = Integer.parseInt(s1[2]);
        String[] sa = in.readLine().split(" ");
        String[] sb = in.readLine().split(" ");
        for(int i = 0; i < n; i ++ ) a[i] = Integer.parseInt(sa[i]);
        for(int i = 0; i < m; i ++ ) b[i] = Integer.parseInt(sb[i]);
        for(int i = 0, j = m - 1; i < n; i ++ ){
            while(j >= 0 && a[i] + b[j] > x) j -- ;
            if(j >= 0 && a[i] + b[j] == x) System.out.println(i + " " + j);
        }
    }
}
